<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<%@ include file="/include/header.jsp"%>
<title><s:text name="register.sendEmailPage"/></title>

<link rev="stylesheet" media="all" href="${baseURL}/fare/css/form_style.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="${baseURL}/js/jquery/validate/jquery.metadata.js"></script>
<script type="text/javascript" src="${baseURL}/js/jquery/validate/jquery.validate.min.js"></script>
<script type="text/javascript">
var head = document.getElementsByTagName("head")[0];
var scriptLink = document.createElement("script");
scriptLink.type = "text/javascript";
head.appendChild(scriptLink);
var language = "${sessionScope.currentLanguage}";
if(language=='' || language == 'china'){
	scriptLink.src = "${baseURL}/js/jquery/validate/messages_cn.js";
}
$(function(){
	//邮箱与所属公司从注册页带值过来
	$("#emailAdress").val(parent.document.getElementById("email").value);
	var hbaseKey = parent.document.getElementById("select_dpmt").value;
	$("#company option[value='"+hbaseKey+"']").attr("selected", true);

	$("#form1").validate();
	//确认发送按钮
	$("#querybutton").click(function(){
		if($("#form1").valid()){//验证是否通过
			$.ajax({
				type : "post",
				async : false,//同步
				url : baseURL+"/register/sendcoderequest/request.action",
				data : $("#form1").serialize(),
				dataType: "json",
				success: function (data){
					if(data && data.hasOk){
						alert("<s:text name='register.alertSuccess'/>");
						parent.layer.close(1);
					}else{
						alert(data.message);
					}
				}
			}); 
		}
	});
	//清空
	$("#cancelbutton").click(function(){
		$('#emailAdress').val("");
		$('#company').val("");
		$('#emailBody').val("");
	});
});

//限制字数
function textDown(){
	var textDatas=document.getElementById('emailBody').value;
	var alertNumber=document.getElementById('register.alertNumber').value;
	if(textDatas.length >= 500){
		document.getElementById('emailBody').value=textDatas.substring(0,500);
		alert(alertNumber);
	} 
}
</script>
</head>

<body>
	<div class="form_body">
		<div class="main_max" style="width:700px">
			<div class="high_10"></div>
			<form method="post" id="form1" name="form1" 	action="">
				<input type="hidden" id="register.validated" value="<s:text name="register.validated"/>" /> 
				<input type="hidden" id="register.inputEmail" value="<s:text name="register.inputEmail"/>" />
				<input type="hidden" id="register.emailCheck" value="<s:text name="register.emailCheck"/>" />
				<input type="hidden" id="register.enterRight" value="<s:text name="register.enterRight"/>" />
				<input type="hidden" id="register.lenghtEr" value="<s:text name="register.lenghtEr"/>" />
				<input type="hidden" id="register.emailFormatEr" value="<s:text name="register.emailFormatEr"/>" />
				<input type="hidden" id="register.alertSuccess" value="<s:text name="register.alertSuccess"/>" />
				<input type="hidden" id="register.alertError" value="<s:text name="register.alertError"/>" />
				<input type="hidden" id="register.alertNumber" value="<s:text name="register.alertNumber"/>" />
				<input type="hidden" id="register.inputEmail" value="<s:text name="register.inputEmail"/>" />
				<input type="hidden" id="register.choiseCompanyName" value="<s:text name="register.choiseCompanyName"/>" />
				<input type="hidden" id="register.emailFormatEr2" value="<s:text name="register.emailFormatEr2"/>" />
				
				<table width="0" border="0" cellpadding="0" cellspacing="0" class="form_table">
					<tr>
						<td class="left" style="width: 150px;"><s:text name="register.yourEmail"/>:</td>
						<td><input name="emailAdress" type="text" id="emailAdress" style="width: 200px"
						class="{required:true,minlength:1,maxlength:50,email:true}"/>
						</td>
					</tr>
					<tr>
						<td class="left"><s:text name="register.yourcompany"/>:</td>
						<td><select name="company" id="company"
							style="width: 200px; padding: 0px;"
							class="{required:true}">
								<option value=""><s:text name="register.select"/></option>
								<c:forEach var="bean" items="${sourceList}" varStatus="stat">
								<option value="${bean.hbaseKey}">${bean.name}</option>
								</c:forEach>
						</select></td>
					</tr>
					<tr>
						<td class="left"><s:text name="register.text"/>:</td>
						<td><textarea id="emailBody"  style="overflow:hidden;resize:none;"
						name="emailBody" cols="80" rows="8" 
						class="{required:true,minlength:1,maxlength:500}"><s:text name="register.requestText"/></textarea>
						</td>
					</tr>
				</table>
				<br/>
				<center>
				<input type="button" class="<s:i18n name='forms'><s:text name='forms.btn13'></s:text></s:i18n>" id="querybutton" name="querybutton"/>
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
				<input type="button" class="<s:i18n name='forms'><s:text name='forms.btn02'></s:text></s:i18n>" name="cancelbutton" id="cancelbutton"/>
				</center>
			</form>	
			</div>
</body>
</html>